<?php
define('CONTENT_TYPE', 'Content-Type');
class HttpResponse {
    private $headers;
    
    public function __construct() {
    }
    
    public function setHeader($key, $value) {
        $this->headers[$key] = $value;
        header("{$key}: {$value}");
    }
    
    public function getHeader($key) {
        if(isset($this->headers[$key])) {
            return $this->headers[$key];
        }
        return NULL;
    }
    
    public function getContentType() {
        return $this->getHeader(CONTENT_TYPE);
    }
    
    public function setContentType($content_type) {
        $this->setHeader(CONTENT_TYPE, $content_type);
    }
    
    public function json($value) {
        $this->setContentType('text/plain');
        return json_encode($value);
    } 
    
}
?>